package com.iss.demo.controller;

import com.iss.demo.entity.ShopCar;
import com.iss.demo.model.MyResponseData;
import com.iss.demo.service.ShopCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("shopcar/")
public class ShopCarController {

    @Autowired
    private ShopCarService service;

    @RequestMapping("selectAllById")
    public List<ShopCar> selectAllById(Integer u_id){
        return service.selectAllById(u_id);
    }

    @RequestMapping("selectCountById")
    public MyResponseData selectCountById(Integer u_id){
        MyResponseData responseData=new MyResponseData();
        responseData.setErrorCode(service.selectCountById(u_id));
        return responseData;
    }

    @RequestMapping("insertShop")
    public MyResponseData insertShop(ShopCar shopCar){
        Integer count=service.insertShop(shopCar);
        MyResponseData responseData = new MyResponseData();
        responseData.setErrorCode(count);
        return responseData;
    }

    @RequestMapping("deleteShop")
    public Integer deleteShopCar(Integer c_id){

        return service.deleteShopCar(c_id);
    }

    @RequestMapping("deleteShopByUid")
    public Integer deleteShopCarByUid(Integer u_id){

        return service.deleteShopCarByUid(u_id);
    }

}
